
Page({
    data: {
         chooseType:2,
         cityValue:null,
         nameValue:'',
         phoneValue:'',
         province:'',
         city:'',
    },
    onLoad:function(opt){
      getApp().getUserInfo().then(res=>{
      var header={
             'openid':res.openid, //公用请求头
             'content-type': 'application/json'
         }
       this.setData({
        userInfo:res,
        header:header
       })  
    
      
     })
     this.setData({
      type:opt.type
     }) 

    },
    onShow:function(){
      var userInfo= wx.getStorageSync('userInfo');
        this.setData({
            userInfo:userInfo
        })
        
       var province= wx.getStorageSync('chooseProvince1')||'';
      var city= wx.getStorageSync('chooseCity1')||'';
       this.setData({
            province:province,
            city:city,
            cityValue:province+city
       })
        

    },
    chooseType:function(e){
        console.log(e.currentTarget.dataset.code)
        this.setData({
            chooseType:e.currentTarget.dataset.code
        })
       
    },
    turnCity:function(){
     
      wx.navigateTo({
        url: '/pages/cityChoose/webView?type=1'
      })
    },
    inputAction:function(e){
        var type=e.currentTarget.dataset.code;
       if (type=='1') {
            this.setData({
              nameValue: e.detail.value
            })
       }else if(type=='2') {
            this.setData({
              phoneValue: e.detail.value
            })
       }else if(type=='3') {
             this.setData({
              contentValue: e.detail.value
            })
       }
       
    },
    subButton:function(){
       console.log('提交')
         if (this.data.nameValue.length<1||this.data.phoneValue.length<1||this.data.province.length<1||this.data.city.length<1) {
              wx.showToast({
              title: '请填写完整信息',
              icon:'none',
              duration: 2000
            })
              return
         }
         
         var _self=this;
         wx.request({
            url: getApp().globalData.baseUrl+'/company/partner',
            method:"GET",
            data:{
              openid:this.data.userInfo.openid,
              name:this.data.nameValue,
              phone:this.data.phoneValue,
              type:5,
              content:this.data.contentValue||'',
              province:this.data.province,
              city:this.data.city
            },
            header: {
                'openid':this.data.userInfo.openid, //公用请求头
                'content-type': 'application/json'
            },
            success: function(res) {
             console.log(res)
              wx.showToast({
              title: '申请成功',
              icon:'none',
              duration: 2000
            })
             
         }
       })
    },
     turnPage:function(){
       

          wx.switchTab({
                  url: '../../pages/home/home'
          })
       
    },
     onShareAppMessage:function(){
         return {
              title: '塔塔诚邀优质厂商入驻',
              path: '/pages/cshhr-n/cshhr?type=1'
            }
    },
    onShareTimeline:function(){
         return {
              title: '塔塔诚邀优质厂商入驻',
              path: '/pages/cshhr-n/cshhr?type=1'
            }
    },
});